package com.encon.projecttracker.server.servlet;

import javax.servlet.ServletException;

import org.apache.log4j.Logger;

import com.encon.projecttracker.rpc.Session;
import com.encon.projecttracker.rpc.exceptions.RpcException;
import com.encon.projecttracker.server.services.SessionService;
import com.encon.projecttracker.server.messages.Messages;

public class SessionServlet extends AbstractServlet implements Session {

	
    	private static final long serialVersionUID = 1L;
	
	private transient Logger log = Logger.getLogger(SessionServlet.class);
	
	private transient SessionService sessionService;
	
	public void init() throws ServletException {
		super.init();
		sessionService = (SessionService)applicationContext.getBean("sessionService"); //$NON-NLS-1$
		if (sessionService==null)
		    throw new ServletException(Messages.getString("Servlet.SessionServiceNotFound")); //$NON-NLS-1$
	}

	
	

	public void closeSession(String sessionId) throws RpcException
	{
		sessionService.releaseSession(getCurrentUserId(), sessionId);
	}

	public String createSession() throws RpcException
	{
		return sessionService.createNewSession(getCurrentUserId());
	}




}
